const addFeedback = (user_id, opinion_context) => {
    const formdata = new FormData();
    formdata.append('user_id', user_id);
    formdata.append('opinion_context', opinion_context);

    return (dispatch) => {
        let url = 'http://www.h5weixin.club:8000/opinion';
        fetch(url, {
            method: 'POST',
            mode: 'cors',
            body: formdata,
        }).then(res => {
            return res.json()
        }).then(res => {
            console.log(res)
            if (res.code == 200) {
                dispatch({
                    type: 'ADD_FEEDBACK',
                    msg: res.msg,
                    // data: res.data,
                    value: opinion_context,
                    index: user_id
                })
            }

        }).catch(err => {
            console.log(err)
        })
    }
}

export default addFeedback;